﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.Composite.Presentation.Events;

namespace CustomProvider.Event
{
    /// <summary>
    /// Uses this event to notify the invitation to play has been rejected
    /// </summary>
    public class NotifyRejectInviteToPlayEvent : CompositePresentationEvent<string> { }

    /// <summary>
    /// Uses this event to notify the invitation to play
    /// </summary>
    public class NotifyInviteToPlayEvent : CompositePresentationEvent<string> { }

    /// <summary>
    /// Uses this event to nofify that there is a new player has been connected to the server
    /// </summary>
    public class NotifyUpdateAlreadyPlayerListEvent : CompositePresentationEvent<string> { }

    /// <summary>
    /// Uses this event to raise end game
    /// </summary>
    public class NotifyEndGameEvent : CompositePresentationEvent<string> { }

    /// <summary>
    /// Uses this event to raise opponent has been disconnected
    /// </summary>
    public class NotifyOpponentDisconnectedEvent : CompositePresentationEvent<string> { }

    /// <summary>
    /// Uses this event to raise Game is finish
    /// </summary>
    public class NotifyGameFinishedEvent : CompositePresentationEvent<string> { }

    /// <summary>
    /// Uses this event to raise TimeOut when establishment communication
    /// </summary>
    public class NotifyTimeOutEvent : CompositePresentationEvent<string> { }

    /// <summary>
    /// Uses this event to display message for users
    /// </summary>
    public class NotifyDisplayMessageOnGUIEvent : CompositePresentationEvent<string> { }

    /// <summary>
    /// Uses this event to notify that the connection to the Server has been established
    /// </summary>
    public class NotifyConnectStatusEvent : CompositePresentationEvent<NotifyConnectStatusEvent.ConnectParam>
    {
        public class ConnectParam
        {
            public bool IsConnected { get; set; }
            public string MsgTxt { get; set; }
            public PlayerInfo PlayerInfo { get; set; }

            public ConnectParam(bool isConnected, string msg, PlayerInfo playerInfo)
            {
                this.IsConnected = isConnected;
                this.MsgTxt = msg;
                this.PlayerInfo = playerInfo;
            }
        }

        public class PlayerInfo
        {
            public string Name { get; set; }
            public string IPAddress { get; set; }

            public PlayerInfo(string name, string ipAddress)
            {
                this.Name = name;
                this.IPAddress = ipAddress;
            }
        }
    }

    /// <summary>
    /// Using this event when the server request to send question to the Clients
    /// </summary>
    public class NotifyStartGameEvent : CompositePresentationEvent<NotifyStartGameEvent.GameInfoParam>
    {
        public class GameInfoParam
        {
            public string Subject { get; set; }
            public string Suggestion { get; set; }
            public int NumCharsOfAnswer { get; set; }
            public string IDPlayer1 { get; set; }
            public string IDPlayer2 { get; set; }
            public string IDPlayerAllowGuess { get; set; }

            public GameInfoParam(string subject, string suggestion, int numCharsOfAnswer, string idplayer1, string idplayer2, string idPlayerAllowGuess)
            {
                this.Subject = subject;
                this.Suggestion = suggestion;
                this.NumCharsOfAnswer = numCharsOfAnswer;
                this.IDPlayer1 = idplayer1;
                this.IDPlayer2 = idplayer2;
                this.IDPlayerAllowGuess = idPlayerAllowGuess;
            }
        }
    }

    /// <summary>
    /// Using this event when the server send result of the answer to the client
    /// </summary>
    public class NotifyAnswerResultEvent : CompositePresentationEvent<NotifyAnswerResultEvent.AnswerResultParam>
    {
        public class AnswerResultParam
        {
            public string IDPlayer { get; set; }
            public string Character { get; set; }
            public bool Result { get; set; }
            public string Positions { get; set; }

            public AnswerResultParam(string idPlayer, string character, bool result, string positions)
            {
                this.IDPlayer = idPlayer;
                this.Character = character;
                this.Result = result;
                this.Positions = positions;
            }
        }
    }
}

